<template>
  <a-form-model
    ref="ruleForm"
    :model="form"
    :rules="rules"
  >
    <a-form-model-item ref="name" prop="name">
      <a-input
        v-model="form.name"
      />
    </a-form-model-item>
  
    <a-form-model-item >
      <a-button type="primary" @click="onSubmit">
        Create
      </a-button>
    </a-form-model-item>
  </a-form-model>
</template>
<script>
export default {
  data() {
    return {
      form: {
        name: '',
      },
      rules: {
        name: [
          { required: true, message: 'Please input Activity name', trigger: 'blur' },
          { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
        ],
      },
    };
  },
  methods: {
    onSubmit() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm() {
      this.$refs.ruleForm.resetFields();
    },
  },
};
</script>
